package com.sitanyun.merchant.guide.presenter.impl;

import com.sitanyun.merchant.guide.model.impl.ForgetPasswordAModelImpl;
import com.sitanyun.merchant.guide.model.inter.IForgetPasswordAModel;
import com.sitanyun.merchant.guide.presenter.callback.CallBack;
import com.sitanyun.merchant.guide.presenter.inter.IForgetPasswordAPresenter;
import com.sitanyun.merchant.guide.view.inter.IForgetPasswordAView;

public class ForgetPasswordAPresenterImpl implements IForgetPasswordAPresenter {
    private IForgetPasswordAView mIForgetPasswordAView;
    private IForgetPasswordAModel mIForgetPasswordAModel;

    public ForgetPasswordAPresenterImpl(IForgetPasswordAView aIForgetPasswordAView) {
        mIForgetPasswordAView = aIForgetPasswordAView;
        mIForgetPasswordAModel = new ForgetPasswordAModelImpl();
    }

    @Override
    public void getLoginphone(String phone) {
        mIForgetPasswordAModel.setLoginphone(phone, new CallBack() {
            @Override
            public void onSuccess(Object response) {
                mIForgetPasswordAView.response(response,mIForgetPasswordAView.RESPONSE_ONE);
            }

            @Override
            public void onError(Throwable t) {
                mIForgetPasswordAView.response(t,mIForgetPasswordAView.RESPONSE_TWO);
            }
        });
    }

    @Override
    public void getsmslogin(String mobile, String type) {
        mIForgetPasswordAModel.setsmslogin(mobile, type, new CallBack() {
            @Override
            public void onSuccess(Object response) {
                mIForgetPasswordAView.getresponsesms(response,mIForgetPasswordAView.RESPONSE_ONE);
            }

            @Override
            public void onError(Throwable t) {
                mIForgetPasswordAView.getresponsesms(t,mIForgetPasswordAView.RESPONSE_TWO);
            }
        });
    }

    @Override
    public void getsmscode(String phone, String code, String type) {
        mIForgetPasswordAModel.setsmslogin(phone, code, type, new CallBack() {
            @Override
            public void onSuccess(Object response) {
                mIForgetPasswordAView.responsesms(response,mIForgetPasswordAView.RESPONSE_ONE);
            }

            @Override
            public void onError(Throwable t) {
                mIForgetPasswordAView.responsesms(t,mIForgetPasswordAView.RESPONSE_TWO);
            }
        });
    }

    @Override
    public void getpaswd(String phone, String sms, String password) {
        mIForgetPasswordAModel.setpaswd(phone, sms, password, new CallBack() {
            @Override
            public void onSuccess(Object response) {
                mIForgetPasswordAView.yzpassword(response,mIForgetPasswordAView.RESPONSE_ONE);
            }

            @Override
            public void onError(Throwable t) {
                mIForgetPasswordAView.yzpassword(t,mIForgetPasswordAView.RESPONSE_TWO);
            }
        });
    }
}
